<?php
/**
 * 省市区
 */

namespace app\admin\controller;


use app\admin\model\Region as RegionModel;
use app\common\controller\AdminController;
use think\Exception;

class Region extends AdminController {

    protected $isArrayResult = ['citylist'];

    protected $notNeedAuthAction = ['citylist', 'mycitylist'];

    /**
     * 所有城市列表
     * @return false|string
     */
    public function cityList() {
        try {
            $params = $this->checkParams('');
            if ($params === false) return $this->resErr();
            $list = RegionModel::cityList();//城市
            return $this->resData('success', $list);
        } catch (Exception $e) {
            return $this->resErr($e->getMessage(), $e->getCode());
        }
    }

    /**
     * 可操作的城市
     * @return false|string
     */
    public function myCityList() {
        try {
            $params = $this->checkParams('');
            if ($params === false) return $this->resErr();
            $list = RegionModel::myCityList($params);//城市
            return $this->resData('success', $list);
        } catch (Exception $e) {
            return $this->resErr($e->getMessage(), $e->getCode());
        }
    }

}
